﻿using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Style.eCommerce.API.APIReferences.ComercioLibre;
using Style.eCommerce.API.Mapper;
using Style.eCommerce.API.Models;

namespace Style.eCommerce.API.Tests.Mapper
{
    [TestClass]
    public class EntityMapperTest
    {
        [TestMethod]
        public void MapCLProduct()
        {
            // Arrange
            var clProduct = new CLProduct()
            {
                Id = 3,
                Images = new string[] { "1", "2" },
                Price = 30.5M,
                Stock = 100,
                Title = "Bravia"
            };

            // Act
            var product = EntityMapper.Map(clProduct);

            // Assert
            Assert.AreEqual(clProduct.Id, product.Id);
            Assert.AreEqual(clProduct.Images.Count(), product.Images.Count());
            Assert.AreEqual(clProduct.Images.ElementAt(0), product.Images.ElementAt(0));
            Assert.AreEqual(clProduct.Images.ElementAt(1), product.Images.ElementAt(1));
            Assert.AreEqual(clProduct.Price, product.Price);
            Assert.AreEqual(clProduct.Stock, product.Stock);
            Assert.AreEqual(clProduct.Title, product.Title);
        }

        [TestMethod]
        public void MapCLProductSummary()
        {
            // Arrange
            var clProduct = new CLProductSummary()
            {
                Id = 3,
                Image = "1",
                Title = "Bravia"
            };

            // Act
            var product = EntityMapper.Map(clProduct);

            // Assert
            Assert.AreEqual(clProduct.Id, product.Id);
            Assert.AreEqual(clProduct.Image, product.Image);
            Assert.AreEqual(clProduct.Title, product.Title);
        }
    }
}
